package dao;

import entity.Person;
import java.util.Arrays;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

public class PersonDAO extends DAO<Person> {

    public PersonDAO(EntityManagerFactory emf) {
        super(emf);
    }

    @Override
    protected Root from(CriteriaQuery cq) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    protected boolean exists(Person object) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
    public List findBySSN(String[] ssns) {
        EntityManager entityManager = getEntityManager();
        Query query = entityManager.createQuery("SELECT p FROM Person p where p.SSN in :ssns");
        query.setParameter("ssns", Arrays.asList(ssns));
        
        return query.getResultList();
    }

}
